<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title><{$title}></title>
    <link rel="stylesheet" href="./public/css/bootstrap.min.css">
    <link rel="stylesheet" href="./public/my.css">
</head>
<body>
    <div class="container">
        <h1><span class="glyphicon glyphicon-user"></span> <{$title}></h1>
        <div class="center-block mt20">
            <a href="./index.php?c=User&a=index" class="btn btn-info">首页</a>
            <a href="./index.php?c=User&a=add" class="btn btn-success">添加</a>
        </div>
        <{block name="main"}>
        <table class="table table-hover mt20">
            <tr>
                <td>ID</td>
                <td>姓名</td>
                <td>性别</td>
                <td>年龄</td>
                <td>省份</td>
                <td>操作</td>
            </tr>
            <{foreach $list as $v}>
            <tr>
                <td><{$v.id}></td>
                <td><{$v.name}></td>
                <td>
                    <{if $v.sex == 0}>女
                    <{elseif $v.sex == 1}>男
                    <{else}>人妖
                    <{/if}>
                </td>
                <td><{$v.age}></td>
                <td><{$v.province}></td>
                <td class="col-md-2">
                    <a href="./index.php?c=User&a=edit&id=<{$v.id}>" class="btn btn-primary">编辑</a>
                    <button onclick="del(this)">删除</button>
                </td>
            </tr>
            <{/foreach}>
        </table>
        <{/block}>
    </div><!--END container-->
    

    <script src="./public/js/jquery.min.js"></script>
    <script src="./public/js/bootstrap.min.js"></script>
</body>
<script>
    function del(obj){
      
        var id =  $(obj).parent().parent().children(':eq(0)').html();
       $.ajax({
         type:'get',
         url:'index.php?c=User&a=del',
         data:{id:id},
         success:function(e){
            if(e==1){
                  $(obj).parent().parent().remove(); 
            }else{
                alert('删除失败');
            }
         }
       });
       
    }

</script>
</html>